﻿/*****************************************************************//**
 * @file    FITKGraphObjectRefNode.h
 * @brief   Graph object for geometry 'ref-point'.
 *
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-04-11
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTREFNODE_H__
#define __FITKGRAPHOBJECTREFNODE_H__

#include "FITKGraphObject3D.h"

#include "FITKVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkPoints;
class vtkCellArray;
class vtkStringArray;
class vtkPolyData;
class vtkTextProperty;

class FITKPolyRenderStrategy;
class FITKGraphActor2D;

namespace Interface
{
    class FITKAbaRefPoint;
}

namespace Exchange
{
    /**
     * @brief   Graph object for geometry 'ref-point'.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-04-11
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectRefNode : public FITKGraphObject3D
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectRefNode, FITKGraphObject3D);
        FITKCLASS(Exchange, FITKGraphObjectRefNode);

    public:
        /**
         * @brief   Constructor.
         * @param   caseData: The case data
         * @param   refNode: The ref-node data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        FITKGraphObjectRefNode(AbaqusData::FITKDataCase* caseData, Interface::FITKAbaRefPoint* refNode);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        virtual ~FITKGraphObjectRefNode();

        /**
         * @brief   Pre-highlight the graph actors.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-24
         */
        void preHighlight() override;

        /**
         * @brief   Highlight the ref-node graph actors.[override]
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        void highlight(QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the ref-node graph actors.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        void disHighlight() override;

        /**
         * @brief   Update the ref-node label and position.[override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-14
         */
        void update(bool forceUpdate = false) override;

        /**
         * @brief   Get the fixed sized bounds of this graph object.[override]
         * @param   The bounds size
         * @return  If the graph object has fixed sized bounds
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-17
         */
        bool getFixedBounds(double* bounds) override;

        /**
         * @brief   Set if the graph object can be picked.[override]
         * @param   isPickable: Pickable
         * @param   dim: The dimision of the pickable object( -1 means the whole graph object )[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-23
         */
        void setPickable(bool isPickable, int dim = -1) override;

#ifdef QT_DEBUG
        /**
         * @brief   Simplified the graph object if necessary.[override]
         * @param   enabled: Enabled simplified flag
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-20
         */
        void simplified(bool enabled) override;
#endif // QT_DEBUG

    protected:
        /**
         * @brief   Initialize.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        void init();

        /**
         * @brief   Generate ref node actor.
         * @param   name: Ref-node name
         * @param   pos: Position
         * @param   fontSize: The label font size ( -1 means use default size )[default]
         * @param   shapeSize: The label shape size ( -1 means use default size )[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        void generateGraph(QString name, double* pos, double fontSize = -1., double shapeSize = -1.);

    protected:
        /**
         * @brief   The points data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        vtkPoints* m_points{ nullptr };

        /**
         * @brief   The cells data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        vtkCellArray* m_cells{ nullptr };

        /**
         * @brief   The string array stored the text of labels.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        vtkStringArray* m_textArray{ nullptr };

        /**
         * @brief   The poly data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        vtkPolyData* m_polyData{ nullptr };

        /**
         * @brief   The actor for the pickable point 3D in world.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-17
         */
        FITKGraphActor* m_fActorPoint3D{ nullptr };

        /**
         * @brief   The actor 2D for label text.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-31
         */
        FITKGraphActor2D* m_fActorText2D{ nullptr };

        /**
         * @brief   The actor 2D for the glyph shape label.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-31
         */
        FITKGraphActor2D* m_fActorShape2D{ nullptr };

        /**
         * @brief   The label font size.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        double m_fontSize = 18.;

        /**
         * @brief   The label shape size.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        double m_glyphSize = 25.;

        /**
         * @brief   The label text property.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        vtkTextProperty* m_textProperty{ nullptr };

        /**
         * @brief   The mapper's strategy of the shape label.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-11
         */
        FITKPolyRenderStrategy* m_strategyShape{ nullptr };

    };
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTREFNODE_H__
